Previous Book Contents Book Index Next

Inside Macintosh: Programming With JManager /
Chapter 1 - Using JManager / Creating an AWT Context


Displaying Frames

As explained earlier, a Java program displays graphical output in virtual windows called frames. Since frames correspond to Mac OS windows, you can manipulate them in a similar manner (for example, create or destroy frames, resize them, and so on).

In order to communicate between the abstract frames and the actual Mac OS windows, you must designate a number of application-defined callback functions. Many of these functions correspond to similar Mac OS Toolbox functions. The application-defined functions and their corresponding Mac OS Toolbox functions are shown in Table 1-1. For details of the structure of these functions, see "Application-Defined Functions" (page 97).
Table 1-1 Application-defined frame functions
Frame functionDescriptionCorresponding Mac OS Toolbox function
MyRequestFrameCreates a new windowGetNewCWindow, NewCWindow, GetNewWindow, or NewWindow
MyReleaseFrameDisposes of a windowDisposeWindow
MySetUpPortSets up a graphics portGetPort(&gSave) and SetPort
MyRestorePortRestores a graphics portSetPort(gSave)
MyResizeRequestRequests that a window be resizedSizeWindow
MyInvalRectInvalidates a portion of a windowInvalRect
MyShowHideShows or hides a windowShowHide or ShowWindow and HideWindow
MySetTitleSets the window title barSetWTitle
MyCheckUpdateChecks to see if a window update is necessaryCheckUpdate or BeginUpdate and EndUpdate

Typically the bulk of an application-defined frame function is spent preparing a call to the corresponding Mac OS Toolbox function. For example, assuming that the application uses the functions in Listing 1-7 (page 16) and Listing 1-8 (page 17), you can use the callback function in Listing 1-9 to set the window title.

Listing 1-9 A callback function to change the title of a window

void MySetTitle(JMFrameRef frame, Str255 title)
{
   WindowPtr win = getFrameWindow(frame);
   if (win)
      SetWTitle(win, title);
}

Previous Book Contents Book Index Next

© Apple Computer, Inc.
23 APR 1997